<style>
	.box-body{width: 800px;}
	
</style>
    <input type="hidden" id="type" name="type" value="<{$type}>" />
    
        <div class="box-body">
            <table class="table ">
                <colgroup>
                    <col style="width: 15%;"></col>
                    <col style="width: 80%;"></col>
                </colgroup>

                <tr>
                    <th class="th-label" style="border: none;background-color: #FFFFFF;">标题：</th>
                    <td style="border: none;">
                        <input class="form-control inline" type="text" name="message_title" id="message_title" value="<{$data.message_title}>" />
                    </td>
                </tr>

                <tr>
                    <th class="th-label" style="border: none;background-color: #FFFFFF;">内容：</th>
                    <td style="border: none;">
                        <textarea rows="5" class="form-control" id="message_content" name="message_content"><{$data.message_content}></textarea>
                    </td>
                </tr>

            </table>
        </div>

        <div class="box-footer">
            <button type="button" id="sub" class="btn btn-default" style="margin-left: 84px;">保存</button>
        </div>
    
<script>
	$(document).on('click','#sub',function(){
        	var g = $('input[name="g"]').val();
	        var url = '?r=system/doEdit&g='+g;
        	
        	var type = $('input[name="type"]').val();
        	var message_title = $('input[name="message_title"]').val();
        	var message_content = $('textarea[name="message_content"]').val();
        	if(type == ''){
        		layer.alert('非法操作', {icon: 2, skin: 'layui-layer-molv'});
        		return false;
        	}
        	if(message_title == ''){
        		layer.alert('请填写标题', {icon: 2, skin: 'layui-layer-molv'});
        		return false;
        	}      	
        	
        	if(message_content == ''){
        		layer.alert('请填写内容', {icon: 2, skin: 'layui-layer-molv'});
        		return false;
        	}
        	
        	var message_content_l = message_content.length;
        	if(message_content_l > 500){
        		layer.alert('内容不能超过500字', {icon: 2, skin: 'layui-layer-molv'});
        		return false;
        	}
        	
        	
          	$.ajax({
	        	type : 'POST',
	        	url : url,
	        	async:false,
	        	data : {'type':type,'message_title':message_title,'message_content':message_content},
		        dataType :'JSON',
		        success : function(res){
		        	if(res.status){		
					   layer.alert('设置成功', {icon: 1, skin: 'layui-layer-molv'});
			        }else{
			        	layer.alert(res.msg, {icon: 2, skin: 'layui-layer-molv'});
			        	
			        }
		        }
	        });
    });
</script>